package com.white.androidstudy.main;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;

import com.white.androidstudy.MyScrollViewActivity;
import com.white.androidstudy.R;
import com.white.androidstudy.RecycleEmbededActivity;
import com.white.androidstudy.WatchActivity;
import com.white.androidstudy.WidgetShowActivity;
import com.white.commonlib.manager.LogManager;
import com.white.ndkmaster.NativeX;

public class LaunchActivity extends AppCompatActivity
{

    private RecyclerView cycle;
    String[] functions;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);

        init();
    }

    private void init()
    {
        cycle = (RecyclerView) findViewById(R.id.recycle);

        functions = getResources().getStringArray(R.array.function);
        LaunchAdapter ad = new LaunchAdapter(functions);
        GridLayoutManager m = new GridLayoutManager(this, 3, OrientationHelper.VERTICAL, false);
        cycle.setLayoutManager(m);
        cycle.setAdapter(ad);
        GridStaggerDivider d = new GridStaggerDivider(this);
        d.setDividerStyle(50, Color.TRANSPARENT);
        cycle.addItemDecoration(d);
        ad.setOnItemClickListener(new LaunchAdapter.OnItemClickListener()
        {
            @Override
            public void onClick(int position, String item)
            {
                switch (position)
                {
                    case 0:
                        startActivity(new Intent(LaunchActivity.this, WidgetShowActivity.class));
                        break;
                    case 1:
                        startActivity(new Intent(LaunchActivity.this, RecycleEmbededActivity.class));
                    case 2:
                        startActivity(new Intent(LaunchActivity.this, MyScrollViewActivity.class));
                    case 3:
                        startActivity(new Intent(LaunchActivity.this, WatchActivity.class));
                }
            }
        });
    }
}
